<?php
extract($_POST);
include("dll/config.php");

//Conectarse a la bd
		$conexion= mysql_connect($db_host, $db_user, $db_password);
		mysql_select_db($db_name, $conexion);
	    //fin de la conexi
		$sql="SELECT *
FROM `usuarios`
WHERE correo = '$usuario'
AND clave = '$contrasena'";
                    
		$res=mysql_query($sql, $conexion);
		$total=mysql_num_rows($res);
		echo $total;
		if($total>0){
			while ($total=mysql_fetch_assoc($res)) {
				$id= $total['id'];
				$nombres= $total['nombre'];
				$email= $total['correo'];	
                                
			}

			session_start();
			$_SESSION['val_session1'] = $id;
			$_SESSION['val_session2'] = $email;
			

        /* echo "<script>location.href='../crearproy.php'</script>"; */
			Header('Location: ../crearproy.php');

		}else{
                    
                        $sql2=$sql="SELECT *
FROM `colaboradores`
WHERE mail = '$usuario'
AND contrasena = '$contrasena'";
                        
                        $res=mysql_query($sql2, $conexion);
                        $total=mysql_num_rows($res);
                        echo $total;
                        if($total>0){
                            while ($total=mysql_fetch_assoc($res))  {
                                    $email= $total['mail'];
                                    $id= $total['idColaborador'];
                                    $idProyecto=$total['idProyecto'];
                            }

			session_start();
			  $_SESSION['val_session1'] = $id;
			$_SESSION['val_session2'] = $email;
                        $_SESSION['val_session3'] =$idProyecto;
                      
                        Header('Location: ../ModuloEstimacionTiempo/estimaColaborador.php');
                    	
                        }
                            else{
                                echo "<script>alert('Fallo Ingreso')</script>";       
                        }
                }
?>